<template>
  <div class="suggestions-container">
    <!-- 页面标题区域 -->
    <div class="page-header">
      <div class="header-content">
        <div class="header-icon">
          <el-icon><Lock /></el-icon>
        </div>
        <div class="header-text">
          <h1>安全加固指南</h1>
          <p>专业漏洞修复方案与安全最佳实践</p>
        </div>
      </div>
    </div>
    
    <!-- 主内容卡片 -->
    <el-card class="main-card">
      <!-- 返回按钮 (当从特定漏洞详情页面进入时显示) -->
      <div v-if="vulnId" class="back-button-container" style="margin-bottom: 20px;">
        <el-button @click="router.back()" type="default" size="small">
          返回结果页
        </el-button>
      </div>
      <!-- 过滤和搜索区域 -->
      <div class="filter-section">
        <el-form :inline="true" class="suggestion-filter-form">
          <el-form-item>
            <el-select 
              v-model="selectedVulnType" 
              placeholder="请选择漏洞类型"
              @change="loadSuggestion"
              style="width: 220px;"
              class="filter-select">
              <el-option label="所有漏洞" value="all"></el-option>
              <el-option v-for="type in vulnerabilityTypes" :key="type" :label="vulnTypeLabels[type]" :value="type"></el-option>
            </el-select>
          </el-form-item>
          
          <el-form-item>
            <el-select 
              v-model="selectedCodeLanguage" 
              placeholder="代码语言"
              @change="updateCodeExample"
              style="width: 150px;"
              class="filter-select">
              <el-option v-for="lang in codeLanguages" :key="lang" :label="lang" :value="lang"></el-option>
            </el-select>
          </el-form-item>
          
          <el-form-item>
            <el-button 
              type="primary" 
              @click="loadSuggestion" 
              class="refresh-btn"
              :loading="loading">
              <el-icon><Refresh /></el-icon> 刷新建议
            </el-button>
          </el-form-item>
        </el-form>
      </div>
      
      <!-- 统计摘要卡片 -->
      <div v-if="currentSuggestion && selectedVulnType !== 'all'" class="summary-cards">
        <el-card class="summary-card">
          <div class="summary-item">
            <div class="summary-icon">
              <el-icon><Warning /></el-icon>
            </div>
            <div class="summary-text">
              <div class="summary-value">{{ riskScore.toFixed(2) }}</div>
              <div class="summary-label">风险评分</div>
            </div>
          </div>
        </el-card>
        
        <el-card class="summary-card">
          <div class="summary-item">
            <div class="summary-icon">
              <el-icon><ExclamationTriangle /></el-icon>
            </div>
            <div class="summary-text">
              <div class="summary-value">
                <el-tag :type="severityType" size="medium">{{ severityText }}</el-tag>
              </div>
              <div class="summary-label">严重程度</div>
            </div>
          </div>
        </el-card>
        
        <el-card class="summary-card">
          <div class="summary-item">
            <div class="summary-icon">
              <el-icon><CheckStep /></el-icon>
            </div>
            <div class="summary-text">
              <div class="summary-value">{{ currentSuggestion.steps.length }}</div>
              <div class="summary-label">修复步骤</div>
            </div>
          </div>
        </el-card>
      </div>
      
      <!-- 修复建议内容 -->
      <div v-if="currentSuggestion" class="suggestion-content">
        <div class="suggestion-header">
          <div class="suggestion-title-container">
            <h2 class="suggestion-title">{{ currentSuggestion.title }}</h2>
            <el-tag v-if="selectedVulnType !== 'all'" :type="severityType" class="severity-tag">
              {{ severityText }}
            </el-tag>
          </div>
          <div class="risk-score">
            <span class="score-label">风险评分:</span>
            <span :class="['score-value']" :style="{color: riskScoreColor}">
              {{ riskScore.toFixed(2) }}
            </span>
          </div>
        </div>
        
        <div class="suggestion-body">
          <!-- 问题描述 -->
          <div class="section">
            <div class="section-header">
              <el-icon><Warning /></el-icon>
              <h4 class="section-title">问题描述</h4>
            </div>
            <p class="section-content">{{ currentSuggestion.description }}</p>
          </div>
          
          <!-- 修复步骤 -->
          <div class="section">
            <div class="section-header">
              <el-icon><Checklist /></el-icon>
              <h4 class="section-title">修复方案</h4>
            </div>
            <div class="steps-container">
              <div class="step-item" v-for="(step, index) in currentSuggestion.steps" :key="index">
                <div class="step-number">{{ index + 1 }}</div>
                <div class="step-content">{{ step }}</div>
              </div>
            </div>
          </div>
          
          <!-- 代码示例 -->
          <div v-if="currentCodeExample" class="section">
            <div class="section-header">
              <el-icon><Code /></el-icon>
              <h4 class="section-title">代码参考 ({{ selectedCodeLanguage }})</h4>
              <el-button 
                @click="copyToClipboard" 
                type="primary" 
                size="small" 
                class="copy-btn"
                :loading="copying">
                <el-icon v-if="!copying"><CopyDocument /></el-icon>
                <el-icon v-else><Loading /></el-icon>
                {{ copying ? '复制中...' : '复制代码' }}
              </el-button>
            </div>
            <div class="code-container">
              <div class="code-header-bar">
                <div class="code-language">{{ selectedCodeLanguage }}</div>
                <div class="code-actions">
                  <el-tooltip content="语法高亮已启用">
                    <el-icon class="code-action-icon"><Highlight /></el-icon>
                  </el-tooltip>
                </div>
              </div>
              <pre class="code-block"><code>{{ currentCodeExample }}</code></pre>
            </div>
          </div>
          
          <!-- 风险评估 -->
          <div class="section">
            <div class="section-header">
              <el-icon><Risk /></el-icon>
              <h4 class="section-title">风险评估</h4>
            </div>
            <div class="risk-metrics">
              <div class="risk-item">
                <label>风险评分</label>
                <div class="risk-score-container">
                  <span class="risk-score">{{ riskScore.toFixed(2) }}</span>
                  <div class="risk-progress">
                    <el-progress :percentage="riskScore * 100" :type="'line'" :stroke-width="8" :show-text="false" :color="riskScoreColor"/>
                  </div>
                </div>
              </div>
              <div class="risk-item">
                <label>严重程度</label>
                <div class="severity-display">
                  <el-tag :type="severityType" size="large">{{ severityText }}</el-tag>
                </div>
              </div>
              <div class="risk-item">
                <label>潜在影响</label>
                <div class="impact-description">{{ impactDescription }}</div>
              </div>
            </div>
          </div>
          
          <!-- 相关资源链接 -->
          <div v-if="relatedResources && relatedResources.length > 0" class="section">
            <div class="section-header">
              <el-icon><Link /></el-icon>
              <h4 class="section-title">相关资源</h4>
            </div>
            <div class="resources-list">
              <el-tag 
                v-for="(resource, index) in relatedResources" 
                :key="index"
                type="info"
                :closable="false"
                class="resource-tag hover-effect"
                @click="openResource(resource.url)">
                <el-icon class="tag-icon"><Document /></el-icon>
                {{ resource.name }}
              </el-tag>
            </div>
          </div>
        </div>
      </div>
      
      <!-- 空状态 -->
      <div v-else class="empty-state">
        <el-empty description="请选择漏洞类型查看修复建议"></el-empty>
      </div>
    </el-card>
  </div>
</template>

<script setup>
import { ref, computed, onMounted, watch } from 'vue'
import { ElMessage, ElIcon, ElNotification } from 'element-plus'
import { useRoute, useRouter } from 'vue-router'
import { 
  CopyDocument, 
  Lock as Shield, // 用Lock替代Shield
  Refresh, 
  Warning, 
  WarningFilled as ExclamationTriangle, // 用WarningFilled替代ExclamationTriangle
  Check as CheckStep, // 用Check替代CheckStep
  Check as Checklist, // 用Check替代Checklist
  CircleCheck as CodeIcon, // 用CircleCheck替代Code
  Loading, 
  Star as Highlight, // 用Star替代Highlight
  Bell as Risk, // 用Bell替代Risk
  Link, 
  Document 
} from '@element-plus/icons-vue'
import apiService from '@/services/apiService.js'
import { repairSuggestions } from '@/utils/repairSuggestions.js'

// 漏洞类型和标签映射
const vulnerabilityTypes = ['sql_injection', 'xss', 'info_leak', 'command_injection', 'csrf']
const vulnTypeLabels = {
  'sql_injection': 'SQL注入',
  'xss': '跨站脚本(XSS)',
  'info_leak': '信息泄露',
  'command_injection': '命令注入',
  'csrf': '跨站请求伪造'
}

// 支持的代码语言
const codeLanguages = ['python', 'javascript', 'java', 'php', 'apache', 'nginx']

// 组件状态
const route = useRoute()
const router = useRouter()
const selectedVulnType = ref('all')
const selectedCodeLanguage = ref('python')
const currentSuggestion = ref(null)
const currentCodeExample = ref(null)
const riskScore = ref(0.75)
const severityText = ref('medium')
const copying = ref(false)
const relatedResources = ref([])
const loading = ref(false)
const vulnId = ref(null)

// 严重程度标签类型
const severityType = computed(() => {
  switch(severityText.value) {
    case 'high': return 'danger'
    case 'medium': return 'warning'
    case 'low': return 'success'
    default: return 'info'
  }
})

// 风险评分颜色
const riskScoreColor = computed(() => {
  if (riskScore.value >= 0.8) return '#f56c6c'
  if (riskScore.value >= 0.5) return '#e6a23c'
  return '#67c23a'
})

// 潜在影响描述
const impactDescription = computed(() => {
  const impactMap = {
    'sql_injection': '可能导致未授权的数据访问、修改或删除，严重时可获取服务器控制权',
    'command_injection': '可能导致执行任意系统命令，完全控制系统并获取敏感数据',
    'xss': '可能导致会话劫持、数据窃取和恶意脚本执行，影响用户安全',
    'csrf': '可能导致未授权操作，如资金转账、密码修改等',
    'info_leak': '可能泄露敏感信息，为后续攻击提供便利'
  }
  return impactMap[selectedVulnType.value] || '可能影响系统安全性，建议及时修复'
})

// 加载修复建议
async function loadSuggestion() {
  // 添加加载动画效果
  loading.value = true
  currentSuggestion.value = null
  
  try {
    // 检查是否有漏洞ID参数
    const routeVulnId = route.params.vulnId
    
    if (routeVulnId) {
      // 从后端获取特定漏洞的详情
      vulnId.value = routeVulnId
      const response = await apiService.getVulnerabilityDetails(vulnId.value)
      const vulnData = response.data || response
      
      // 设置当前漏洞类型
      if (vulnData.type) {
        selectedVulnType.value = vulnData.type
      }
      
      // 构建建议对象
      currentSuggestion.value = {
        title: vulnData.title || `漏洞详情 - ${vulnData.type}`,
        description: vulnData.description || '暂无详细描述',
        steps: vulnData.remediation_steps || vulnData.steps || [
          '暂无具体修复步骤，请联系安全团队获取更多信息'
        ],
        code_examples: vulnData.code_examples || {}
      }
      
      // 更新相关数据
      updateCodeExample()
      updateRiskAssessment()
      loadRelatedResources()
      
      // 更新风险评分
      if (vulnData.risk_score) {
        animateValue(riskScore, riskScore.value, vulnData.risk_score, 500)
        severityText.value = vulnData.severity || 
          (vulnData.risk_score >= 0.8 ? 'high' : 
           vulnData.risk_score >= 0.5 ? 'medium' : 'low')
      }
    } else if (selectedVulnType.value === 'all') {
      // 显示默认的通用建议
      currentSuggestion.value = {
        title: '通用漏洞修复建议',
        description: '以下是适用于大多数类型漏洞的通用修复措施。定期进行安全审计和漏洞扫描，确保系统安全。',
        steps: [
          '实施输入验证和输出编码，防止注入攻击',
          '遵循最小权限原则，限制系统和应用程序的访问权限',
          '保持软件和依赖项更新到最新版本，修复已知漏洞',
          '实施适当的访问控制机制，如身份验证和授权',
          '定期进行安全审计和漏洞扫描，发现并修复安全问题',
          '培训开发人员了解安全最佳实践，从源头减少漏洞'
        ]
      }
      currentCodeExample.value = null
      relatedResources.value = []
    } else {
      // 加载特定漏洞类型的建议
      const suggestion = repairSuggestions[selectedVulnType.value]
      if (suggestion) {
        currentSuggestion.value = suggestion
        updateCodeExample()
        updateRiskAssessment()
        loadRelatedResources()
      }
    }
  } catch (error) {
    console.error('加载漏洞详情失败:', error)
    ElMessage.error('加载漏洞详情失败，请稍后重试')
    
    // 加载失败时使用本地数据作为备份
    if (selectedVulnType.value !== 'all') {
      const suggestion = repairSuggestions[selectedVulnType.value]
      if (suggestion) {
        currentSuggestion.value = suggestion
        updateCodeExample()
        updateRiskAssessment()
        loadRelatedResources()
      }
    }
  } finally {
    loading.value = false
  }
}

// 更新代码示例
function updateCodeExample() {
  if (currentSuggestion.value && currentSuggestion.value.code_examples) {
    currentCodeExample.value = currentSuggestion.value.code_examples[selectedCodeLanguage.value] || 
                               Object.values(currentSuggestion.value.code_examples)[0] || null
  } else {
    currentCodeExample.value = null
  }
}

// 更新风险评估
function updateRiskAssessment() {
  // 根据漏洞类型设置风险评分
  const riskMap = {
    'sql_injection': 0.9,
    'command_injection': 0.95,
    'xss': 0.7,
    'csrf': 0.5,
    'info_leak': 0.6
  }
  
  const score = riskMap[selectedVulnType.value] || 0.5
  
  // 添加平滑过渡动画
  animateValue(riskScore, riskScore.value, score, 500)
  
  if (score >= 0.8) {
    severityText.value = 'high'
  } else if (score >= 0.5) {
    severityText.value = 'medium'
  } else {
    severityText.value = 'low'
  }
}

// 加载相关资源链接
function loadRelatedResources() {
  const resourcesMap = {
    'sql_injection': [
      { name: 'OWASP SQL注入防护指南', url: 'https://owasp.org/www-community/attacks/SQL_Injection_Prevention_Cheat_Sheet' },
      { name: 'SQL注入漏洞测试工具', url: 'https://github.com/sqlmapproject/sqlmap' }
    ],
    'xss': [
      { name: 'OWASP XSS防护指南', url: 'https://owasp.org/www-community/xss/' },
      { name: 'XSS过滤库', url: 'https://github.com/leizongmin/js-xss' }
    ],
    'info_leak': [
      { name: '信息泄露防护最佳实践', url: 'https://owasp.org/www-community/attacks/Information_Leakage' },
      { name: '敏感数据扫描工具', url: 'https://github.com/dxa4481/truffleHog' }
    ],
    'command_injection': [
      { name: '命令注入防护指南', url: 'https://owasp.org/www-community/attacks/Command_Injection' },
      { name: '安全命令执行库', url: 'https://github.com/google/google-api-python-client' }
    ],
    'csrf': [
      { name: 'OWASP CSRF防护指南', url: 'https://owasp.org/www-community/attacks/csrf' },
      { name: 'CSRF测试工具', url: 'https://github.com/mebjas/CSRFPoCGenerator' }
    ]
  }
  
  relatedResources.value = resourcesMap[selectedVulnType.value] || []
}

// 复制代码到剪贴板，增强版
async function copyToClipboard() {
  if (!currentCodeExample.value) return
  
  copying.value = true
  
  try {
    // 尝试使用现代的Clipboard API
    if (navigator.clipboard && window.isSecureContext) {
      await navigator.clipboard.writeText(currentCodeExample.value)
      ElMessage.success('代码已成功复制到剪贴板！')
    } else {
      // 降级方案
      const textArea = document.createElement('textarea')
      textArea.value = currentCodeExample.value
      textArea.style.position = 'fixed'
      textArea.style.left = '-999999px'
      textArea.style.top = '-999999px'
      document.body.appendChild(textArea)
      textArea.focus()
      textArea.select()
      
      try {
        document.execCommand('copy')
        ElMessage.success('代码已成功复制到剪贴板！')
      } catch (err) {
        throw new Error('复制命令失败')
      } finally {
        document.body.removeChild(textArea)
      }
    }
    
    // 显示复制成功通知
    ElNotification({
      title: '复制成功',
      message: '代码示例已复制到剪贴板，您可以粘贴到编辑器中使用。',
      type: 'success',
      duration: 3000
    })
  } catch (err) {
    console.error('复制失败:', err)
    ElMessage.error('复制失败，请手动复制代码')
  } finally {
    // 延迟重置复制状态，确保用户看到加载动画
    setTimeout(() => {
      copying.value = false
    }, 500)
  }
}

// 打开相关资源链接
function openResource(url) {
  window.open(url, '_blank')
  ElMessage.success('正在打开资源链接...')
}

// 数值动画函数
function animateValue(ref, start, end, duration) {
  let startTimestamp = null
  const step = (timestamp) => {
    if (!startTimestamp) startTimestamp = timestamp
    const progress = Math.min((timestamp - startTimestamp) / duration, 1)
    // 使用缓动函数使动画更自然
    const easedProgress = progress === 1 ? 1 : 1 - Math.pow(2, -10 * progress)
    ref.value = start + (end - start) * easedProgress
    if (progress < 1) {
      window.requestAnimationFrame(step)
    }
  }
  window.requestAnimationFrame(step)
}

// 监听漏洞类型变化，添加视觉反馈
watch(selectedVulnType, (newType, oldType) => {
  if (newType !== oldType && oldType !== undefined) {
    ElNotification({
      title: '已切换漏洞类型',
      message: `正在显示 ${vulnTypeLabels[newType] || '所有漏洞'} 的修复建议`,
      type: 'info',
      duration: 2000
    })
  }
})

// 组件挂载时加载默认建议
onMounted(() => {
  loadSuggestion()
  
  // 监听路由参数变化
  watch(() => route.params.vulnId, (newVulnId) => {
    if (newVulnId) {
      loadSuggestion()
    }
  })  
  // 添加页面加载动画效果
  document.body.classList.add('page-loaded')
})
</script>

<style scoped>
/* 全局样式 */
.suggestions-container {
  padding: 0;
  min-height: 100vh;
  background: linear-gradient(135deg, #1890ff 0%, #096dd9 100%);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* 页面标题区域 */
.page-header {
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(15px);
  padding: 24px 0;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
  animation: slideDown 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
  position: relative;
  overflow: hidden;
}

.page-header::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 300px;
  height: 300px;
  background: linear-gradient(135deg, rgba(24, 144, 255, 0.05) 0%, rgba(9, 109, 217, 0.1) 100%);
  border-radius: 50%;
  transform: translate(40%, -40%);
  z-index: 0;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  z-index: 1;
}

.header-icon {
  font-size: 36px;
  color: #1890ff;
  background: linear-gradient(135deg, #e6f7ff 0%, #bae7ff 100%);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(24, 144, 255, 0.15);
}

.header-text h1 {
  font-size: 32px;
  font-weight: 700;
  color: #001529;
  margin: 0;
  line-height: 1.2;
}

.header-text p {
  font-size: 16px;
  color: #595959;
  margin: 8px 0 0 0;
  font-weight: 400;
}

/* 主内容卡片 */
.main-card {
  max-width: 1200px;
  margin: 30px auto;
  padding: 32px;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(15px);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.3);
  animation: fadeIn 0.6s cubic-bezier(0.25, 0.8, 0.25, 1);
  position: relative;
  overflow: hidden;
}

.main-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, #1890ff, #52c41a, #faad14, #f5222d);
}

/* 过滤区域 */
.filter-section {
  margin-bottom: 30px;
  animation: fadeIn 0.8s ease-out;
  background: white;
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.suggestion-filter-form {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.filter-select {
  border-radius: 8px !important;
  transition: all 0.3s ease !important;
}

.filter-select:hover {
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2) !important;
}

.refresh-btn {
  border-radius: 8px;
  transition: all 0.3s ease;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
}

.refresh-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* 摘要卡片 */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.summary-card {
  background: linear-gradient(135deg, #f6f9fc 0%, #e9ecef 100%);
  border: none;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
}

.summary-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

.summary-item {
  display: flex;
  align-items: center;
  gap: 16px;
}

.summary-icon {
  font-size: 28px;
  color: #667eea;
}

.summary-value {
  font-size: 28px;
  font-weight: 700;
  color: #1f2937;
}

.summary-label {
  font-size: 14px;
  color: #6b7280;
  margin-top: 4px;
}

/* 建议内容 */
.suggestion-content {
  animation: fadeIn 1s ease-out;
}

.suggestion-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid #e5e7eb;
}

.suggestion-header h2 {
  font-size: 24px;
  font-weight: 700;
  color: #1f2937;
  margin: 0;
}

.severity-badge {
  animation: pulse 2s infinite;
}

.description {
  font-size: 16px;
  line-height: 1.7;
  color: #4b5563;
  margin-bottom: 30px;
  padding: 16px;
  background: #f8fafc;
  border-radius: 8px;
  border-left: 4px solid #667eea;
}

/* 修复步骤区域 */
.steps-section {
  margin-bottom: 30px;
  animation: fadeIn 0.9s ease-out;
}

/* 建议卡片样式 */
.suggestion-content {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.suggestion-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #f0f0f0;
}

.suggestion-title-container {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.suggestion-title {
  font-size: 22px;
  font-weight: 600;
  color: #001529;
  margin: 0;
  line-height: 1.3;
}

.severity-tag {
  font-size: 12px;
  font-weight: 500;
}

.risk-score {
  display: flex;
  align-items: center;
  gap: 8px;
}

.score-label {
  font-size: 14px;
  color: #666;
}

.score-value {
  font-size: 18px;
  font-weight: 600;
}

/* 内容区块样式 */
.suggestion-body {
  margin-top: 20px;
}

.section {
  margin-bottom: 28px;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.section-header h4 {
  font-size: 18px;
  font-weight: 500;
  color: #001529;
  margin: 0;
}

.section-header .el-icon {
  color: #1890ff;
  font-size: 20px;
}

.section-content {
  color: #595959;
  line-height: 1.7;
  margin: 0;
}

/* 步骤样式 */
.steps-container {
  margin-left: 8px;
}

.step-item {
  display: flex;
  margin-bottom: 16px;
  position: relative;
}

.step-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-color: #1890ff;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  margin-right: 16px;
  flex-shrink: 0;
}

.step-content {
  flex: 1;
  color: #595959;
  line-height: 1.6;
  padding-top: 2px;
}

/* 代码块样式 */
.code-container {
  background-color: #f5f5f5;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e8e8e8;
}

.code-header-bar {
  background-color: #1e1e1e;
  padding: 8px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.code-language {
  color: #d4d4d4;
  font-size: 12px;
  font-weight: 500;
}

.code-actions {
  display: flex;
  gap: 8px;
}

.code-action-icon {
  color: #d4d4d4;
  font-size: 16px;
  cursor: pointer;
}

.code-block {
  margin: 0;
  padding: 16px;
  background-color: #1e1e1e;
  color: #d4d4d4;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.5;
  overflow-x: auto;
}

/* 风险评估样式 */
.risk-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.risk-item {
  background-color: #fafafa;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #f0f0f0;
}

.risk-item label {
  display: block;
  font-size: 14px;
  color: #666;
  margin-bottom: 12px;
  font-weight: 500;
}

.risk-score-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.risk-score {
  font-size: 24px;
  font-weight: 600;
  color: #1890ff;
}

.risk-progress {
  flex: 1;
}

.severity-display {
  display: inline-block;
}

.impact-description {
  color: #595959;
  line-height: 1.6;
}

/* 资源链接样式 */
.resources-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.resource-tag {
  background-color: #f0f5ff;
  border-color: #adc6ff;
  color: #1890ff;
  cursor: pointer;
  transition: all 0.3s;
}

.resource-tag:hover {
  background-color: #e6f7ff;
  border-color: #91d5ff;
  transform: translateY(-1px);
}

.tag-icon {
  margin-right: 4px;
}

/* 复制按钮样式 */
.copy-btn {
  padding: 4px 12px;
  height: 28px;
}

/* 响应式调整 */
@media (max-width: 768px) {
  .page-content {
    padding: 20px;
  }
  
  .header-content {
    flex-direction: column;
    text-align: center;
    gap: 12px;
  }
  
  .header-icon {
    width: 48px;
    height: 48px;
    font-size: 24px;
  }
  
  .header-text h1 {
    font-size: 24px;
  }
  
  .suggestion-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
  
  .risk-metrics {
    grid-template-columns: 1fr;
  }
}

.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.section-header h3 {
  font-size: 20px;
  font-weight: 600;
  color: #1f2937;
  margin: 0;
}

.section-header .el-icon {
  color: #667eea;
  font-size: 20px;
}

.step-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.step-card {
  border: none;
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.3s ease;
}

.step-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.15);
}

.step-item {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.step-number {
  min-width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 2px;
}

.step-content p {
  font-size: 15px;
  line-height: 1.6;
  color: #4b5563;
  margin: 0;
}

/* 代码示例 */
.code-section {
  margin-bottom: 40px;
}

.copy-btn {
  border-radius: 6px;
  transition: all 0.3s ease;
}

.copy-btn:hover {
  transform: translateY(-1px);
}

.code-example {
  background-color: #1e293b;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
}

.code-example:hover {
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}

.code-header-bar {
  background-color: #334155;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.code-language {
  color: #e2e8f0;
  font-size: 14px;
  font-weight: 500;
}

.code-actions {
  display: flex;
  gap: 8px;
}

.code-action-icon {
  color: #94a3b8;
  cursor: pointer;
  transition: color 0.3s ease;
}

.code-action-icon:hover {
  color: #e2e8f0;
}

.code-pre {
  margin: 0;
  padding: 20px;
  overflow-x: auto;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

.code-pre code {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 14px;
  line-height: 1.7;
  color: #e2e8f0;
  /* 语法高亮模拟 */
  white-space: pre;
}

/* 风险评估 */
.risk-assessment-section {
  margin-bottom: 40px;
}

.risk-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}

.risk-item {
  background: #f8fafc;
  padding: 20px;
  border-radius: 12px;
  transition: all 0.3s ease;
  border: 1px solid #e2e8f0;
}

.risk-item:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  transform: translateY(-1px);
}

.risk-item label {
  font-size: 14px;
  font-weight: 500;
  color: #6b7280;
  margin-bottom: 12px;
  display: block;
}

.risk-score-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.risk-score {
  font-size: 32px;
  font-weight: 700;
  color: #1f2937;
}

.risk-progress {
  width: 100%;
}

.severity-display {
  display: flex;
  align-items: center;
}

.impact-description {
  font-size: 14px;
  line-height: 1.6;
  color: #4b5563;
}

/* 相关资源 */
.resources-section {
  margin-bottom: 20px;
}

.resources-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.resource-tag {
  background: #e0f2fe;
  color: #0369a1;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: 20px;
  padding: 8px 16px;
}

.resource-tag:hover {
  background: #bae6fd;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(3, 105, 161, 0.2);
}

.tag-icon {
  margin-right: 6px;
}

/* 空状态 */
.empty-state {
  padding: 80px 0;
  text-align: center;
  animation: fadeIn 0.8s ease-out;
}

/* 通用动画类 */
.hover-effect {
  transition: all 0.3s ease;
}

.hover-effect:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.15);
}

/* 动画关键帧 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideDown {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

/* 响应式设计 */
@media (max-width: 768px) {
  .page-header {
    padding: 16px 0;
  }
  
  .header-content {
    padding: 0 16px;
  }
  
  .header-text h1 {
    font-size: 24px;
  }
  
  .main-card {
    margin: 20px;
    padding: 20px;
  }
  
  .suggestion-filter-form {
    flex-direction: column;
    align-items: stretch;
  }
  
  .filter-select {
    width: 100% !important;
  }
  
  .summary-cards {
    grid-template-columns: 1fr;
  }
  
  .risk-metrics {
    grid-template-columns: 1fr;
  }
  
  .suggestion-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .step-item {
    flex-direction: column;
    gap: 12px;
  }
  
  .step-number {
    align-self: flex-start;
  }
}
</style>